{% extends "admin.html" %}

{% block jsfuncs %}

del_post = function(post_id) {
	var req = new Request.HTML({ url: '/admin/posts/del',
	 									  method: 'post',
										  evalScripts : true,
										  data: 'id=' + post_id
										}).send();
	return false;
};


{% endblock %}


{% block content %}
	<h3>{{type|title}}</h3>
	<div id="post_list">
	{% if posts|length %}
	
	<table>
			<tr>
			<td class="td_button"></td>
			<td class="td_button"></td>
			<td class="td_button"></td>
			<th>标题</th>
			<th class="td_date">日期</th>
			</tr>
		{% for post in posts %}
			<tr id="{{ post.key }}">
				<td class="td_button"><a href="#" onclick="javascript:del_post('{{post.key }}');">删除</a></td>	
				<td class="td_button"><a href="edit?id={{ post.key }}" class="edit">编辑</a></td>
				<td class="td_button"><a href="/post/{{ post.permalink }}" class="view">查看</a></td>	
				<td class="post_title{% if post.draft %} draft{%  endif %}">{{ post.title }}</td>
				<td class="td_date">{{ post.created|date:"d/m/Y H:i"}}</td></tr>
		{% endfor %}
	</table>
	<div id="nav">
		{% if navigation.previous_list %}
			<a href="?offset=1" class="nav"><<</a>
			{% for item in navigation.previous_list %}
				<a href="?offset={{item}}" class="nav">{{item}}</a>
			{% endfor %}
		{% endif %}
		<span class="nav current">{{ navigation.current }}</span>
		{% if navigation.next_list %}
			{% for item in navigation.next_list %}
				<a href="?offset={{item}}" class="nav">{{item}}</a>
			{% endfor %}
				<a href="?offset={{navigation.last}}" class="nav">>></a>
		{% endif %}
		
	</div>
	{% else %}
		<h4>没有任何{{type|title}}</h4>
	{% endif %}
	</div>
	<div id="new">
		<a	href="/admin/{{type}}s/new">创建一个新{{type|title}}</a>
	</div>
	
	{% block comments %}

	{% endblock %}
{% endblock %}

